#!/usr/bin/env python
#-*- coding: utf-8 -*-
#
# BSD License
# Copyright (c) 2011, Wang Qiang
# All rights reserved.

from GmailExtension import GmailServer


class EmailSender(object):
    """
    Email Sender. 
    """
    def __init__(self, servertype):
        self.servertype = eval(servertype)

    def SetupServer(self, account, password):
        self.server = self.servertype.SetupServer(account, password)

    def SendEmail(self, sender, receivers, subject, msg):
        self.servertype.SendEmail(self.server, sender, receivers, subject, msg)

class CurrentEmailSender(object):
    """
    Email Sender
    """
    def __init__(self):
        self.sender = EmailSender('GmailServer')
    
    def SendEmail(self, receivers, subject, msg):
        self.sender.SetupServer('wangqiang8511@gmail.com', 'wang8510')
        self.sender.SendEmail('wangqiang8511@gmail.com', receivers, subject, msg)


if __name__ == "__main__":
    sender = CurrentEmailSender()
    sender.SendEmail(['wang0586@e.ntu.edu.sg', 'wolfking222222@163.com'],
                          'Activation Email', 'Hello World!')
